package com.yidu.BusinessData.mapper;


import com.yidu.BusinessData.entity.Exchange;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
@Repository
public interface ExchangeMapper {
    //查询条数
    @Select("select count(*) from ExchangeRate")
    public int selectCount();
    //分页加条件查询
    @Select("select * from ExchangeRate where 1=1 ${splicing} limit #{page},#{limit}")
    public List<Exchange> selectExchange(Map map);

    //判断数据库是否存在
    @Select("SELECT COUNT(*) FROM exchangerate WHERE exchangeName=#{exchangeName} AND exchangeType=#{exchangeType}")
    public int selectExchangeFlag(Exchange exchange);

    //增加数据
    @Insert("insert into ExchangeRate values(#{exchangeName},#{exchangeType},#{transferFee},#{stampDuty},#{handlingFee},#{collectionFee})")
    public int insertExchange(Exchange exchange);
    //删除数据
    @Delete("delete from ExchangeRate where exchangeName=#{exchangeName} and exchangeType=#{exchangeType}")
    public int deleteExchange(Exchange exchange);

    @Update("update ExchangeRate set transferFee=#{transferFee},stampDuty=#{stampDuty},handlingFee=#{handlingFee},collectionFee=#{collectionFee} where exchangeName=#{exchangeName} and exchangeType=#{exchangeType}")
    public int updateExchange(Exchange exchange);
}
